package com.imu.purse.modules.app.service.impl;


import com.github.pagehelper.PageHelper;
import com.imu.core.base.BaseService;
import com.imu.datasources.DataSourceNames;
import com.imu.datasources.annotation.DataSource;
import com.imu.purse.modules.app.dao.ImuUserLogMapper;
import com.imu.purse.modules.app.entity.ImuUserLogEntity;
import com.imu.purse.modules.app.service.ImuUserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 用户信息
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-03-21 10:11:22
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
@Service
public class ImuUserLogServiceImpl extends BaseService<ImuUserLogEntity> implements ImuUserLogService
{
	@Override
    @Transactional
    public int insertUserLog(Integer userId,String opername ,String phone ,Integer operaction ,String remark)
	{

		ImuUserLogEntity imuUserLog = new ImuUserLogEntity();
		imuUserLog.setOperName(opername);
		imuUserLog.setUserId(userId);
		imuUserLog.setOpertime(new Date());
		imuUserLog.setRemark(remark);
		imuUserLog.setOperaction(operaction);
		imuUserLog.setPhone(phone);
    	super.insert(imuUserLog);


    	return 1;
	}

	@Override
	@DataSource(name=DataSourceNames.SECOND)
	public List<ImuUserLogEntity> queryList(ImuUserLogEntity imuUserLog)
	{
		if (imuUserLog.getPage() != null && imuUserLog.getLimit() != null)
		{
			PageHelper.startPage(imuUserLog.getPage(), imuUserLog.getLimit());
		}

		return mapper.findByPage(imuUserLog);
	}

	@Autowired
	private ImuUserLogMapper mapper;

}
